home *** CD-ROM | disk | FTP | other *** search
/ Aminet 32 / Aminet 32 (1999)(Schatztruhe)[!][Aug 1999].iso / Aminet / dev / lang / Python152_Src.lha / Python152_Source / Amiga_Misc / testset / test_misc.py < prev    next >
Text File  |  1998-09-30  |  2KB  |  68 lines

  1. #
  2. #    Test miscellaneous Amiga specific stuff...
  3. #
  4.  
  5. import os
  6. import amiga
  7. import time
  8. import Dos
  9.  
  10. TestError = 'FAILED --- Amiga misc '
  11.  
  12. def testeq(res,check,info):
  13.     if res!=check:
  14.         raise TestError+info
  15.  
  16. def testcrc32(str,check):
  17.     testeq(amiga.crc32(str),check,'amiga.crc32')
  18.  
  19.  
  20. ########################################## amiga.crc32
  21.  
  22. print 'TEST amiga.crc32'
  23. testcrc32('',0xFFFFFFFF)
  24. testcrc32('a',0x174841BC)
  25. testcrc32('abc',0xCADBBE3D)
  26. testcrc32('abcdefghijklmnopqrstuvwxyz',0xB3D8AF42)
  27. testcrc32('ABCDEFGHIJKLMNOPQRSTUVWXYZ',0x540887DD)
  28. testcrc32('12345678901234567890123456789012345678901234567890123456789012345678901234567890  The quick brown Fox jumps over the lazy Dog',0x0383D5D6)
  29. print 'amiga.crc32 TEST OK'
  30.  
  31. print 'TEST Dos.touch, filedates, Amiga dates/times'
  32. try:
  33.     os.remove('t:touchtest')
  34. except os.error:
  35.     pass
  36.  
  37. try:
  38.     Dos.touch('t:touchtest')
  39. except:
  40.     raise TestError+'Dos.touch'
  41.  
  42. try:
  43.     # use Dos.touch to set the filedate to a certain date
  44.     datestr = ('18-Jul-98','13:33:33')
  45.     datestamp = Dos.StrToDate(datestr[0],datestr[1])
  46.     unixtime = Dos.DS2time(datestamp)
  47.     unixtimestr = time.ctime(unixtime)
  48.     testeq(unixtime,900765213.0,'Dos.DS2time')
  49.     testeq(unixtimestr,'Sat Jul 18 13:33:33 1998','Dos.DS2time')
  50.     Dos.touch('t:touchtest',unixtime)
  51.     ds=Dos.Examine('t:touchtest')[Dos.fib_Date]
  52.     testeq(ds, datestamp, 'Dos.touch')
  53.     
  54.     # use Dos.SetFileDate to set the filedate to the current date/time
  55.     datestamp=Dos.DateStamp()
  56.     datestr=Dos.DateToStr(datestamp)
  57.     unixtime = Dos.DS2time(datestamp)
  58.     unixtimestr = time.ctime(unixtime)
  59.     Dos.SetFileDate('t:touchtest',datestamp)
  60.     ds=Dos.Examine('t:touchtest')[Dos.fib_Date]
  61.     testeq(ds, datestamp, 'Dos.SetFileDate')
  62.  
  63.     print 'Dos.touch/Amigadates TEST OK'
  64.  
  65. except:
  66.     raise TestError+'Dos filedates/Amiga dates'
  67.  
  68.